package com.team7.home.controller;


import com.team7.common.vo.CommonResult;
import com.team7.common.vo.LinkVo;
import com.team7.home.service.LinkService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 张煜杰
 * @since 2021-10-21
 */
@RestController

@RequestMapping("/home/link")
public class LinkController {
    @Autowired
    private LinkService linkService;

    @ApiOperation("分页查询的方法")
    @PostMapping("getAllLink/{page}/{limit}")
    public CommonResult getAllLink(@PathVariable("page") Integer page, @PathVariable("limit") Integer limit, @RequestBody LinkVo linkVo){
        return linkService.getAllLink(page,limit,linkVo);
    }

    @PostMapping("changeStatus/{linkId}/{isDisable}")
    public CommonResult changeStatus(@PathVariable("linkId") String linkId,@PathVariable("isDisable") Integer isDisable){
        return linkService.changeStatus(linkId,isDisable);
    }

    @ApiOperation("添加头部导航栏")
    @PostMapping("addLink")
    public CommonResult addLink(@RequestBody LinkVo linkVo){
        return linkService.addLink(linkVo);
    }

    @PostMapping("deleteLink")
    public CommonResult deleteLink(@RequestBody LinkVo linkVo){
        return linkService.deleteLink(linkVo.getLinkId());
    }

}

